$(function() {
	 		var ue = UE.getEditor('editor');
	 		var oUrls = localStorage.getItem('oUrls');
			function details(){
				var id = sessionStorage.getItem("listId")
				ajaxgetData("newDemo/"+id) 
				
				console.log(DataList)
			}
			details()
			var DataList = getData.obj;

				$('#editor').html(DataList.ueditor?DataList.ueditor:"");
				$dp.$('time').value=DataList.date?DataList.date:"";
//			}
			 
		     var viewModel = {       
		     	title: ko.observable(DataList?DataList.title:""),
		     	name: ko.observable(DataList?DataList.name:""),
		     	wantsSpam: ko.observable(true),
		     	isState: ko.observable(DataList?DataList.isState:"0"),
		     	content: ko.observable(DataList?DataList.content:""),
		     };
		     ko.applyBindings(viewModel);
	
			
			$("#button").click(function(){
				if(DataList){
						var obj={
					id:DataList.id,
					title:viewModel.title,
					date:$dp.$('time').value,
					name:viewModel.name,
					isState:viewModel.isState,
					content:viewModel.content,
					ueditor:ue.getContent(),
						}
						
					}else{
						var obj={
					title:viewModel.title,
					date:$dp.$('time').value,
					name:viewModel.name,
					isState:viewModel.isState,
					content:viewModel.content,
					ueditor:ue.getContent(),	
					}
				}
				var params = ko.toJSON(obj);
//				console.log(params)
				ajaxPost("newDemo/save",params) 
				if(PostData.code==0){
					alert("保存成功");
					window.location.href="01-list.html";  
				}
			})

		})		   